package dk.au.cs.peterbn.annotations;

import spoon.reflect.declaration.CtAnnotation;

import java.lang.annotation.*;

/**
 * Declares a method to be a part of a design pattern, fulfilling a role in the pattern.
 */
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Target(ElementType.METHOD)
public @interface Member {

    public enum Fields implements PropertyIdentifier{
        ID("id"),
        ROLE("role"),;
        private final String s;

        Fields(String s) {
            this.s = s;
        }

        @Override
        public String propName() {
            return s;
        }

        public static String val(Fields field, CtAnnotation<Member> annotation) {
            return annotation.getElementValue(field.propName()).toString();
        }
    }

    /**
     * @return The id of the pattern this method is a member of. The id must be declared as the id of one of
     * the surrounding types patterns
     */
    String id();

    /**
     * @return The role the member plays in the surrounding type role.
     */
    String role();

}
